<%@taglib uri="/struts-tags" prefix = "s" %>
<%@ page language="java" import="java.sql.*,java.util.*"
	pageEncoding="utf-8"%>
	<%
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 %>
<%

	
	final int PAGE_SIZE = 2;/*每页显示多少条记录*/
	int pageNo = 1;/*默认从1开始*/
	String strPageNo = request.getParameter("pageNo");
	if (strPageNo != null && !strPageNo.trim().equals("")) {
		try {
			pageNo = Integer.parseInt(strPageNo);
		} catch (NumberFormatException e) {
			pageNo = 1;
		}
	}
	if (pageNo < 0)
		pageNo = 1;
	int totalPages = 0;/*总共记录有多少页*/
	List list = new ArrayList();
	if(request.getAttribute("list")!=null){
		list = (List)request.getAttribute("list");
		}
	if(session.getAttribute("temp")!=null)
		list = (List)session.getAttribute("temp");
// 	List<Article> articles = new ArrayList<Article>();
// 	Connection conn = DB.getConn();
// 	Statement stmtCount = DB.createStmt(conn);
// 	ResultSet rsCount = DB.executeQuery(stmtCount,
// 			"select count(*) from article where pid = 0");
// 	rsCount.next();
	int totalRecords = list.size();
	totalPages = (totalRecords + PAGE_SIZE - 1)/PAGE_SIZE;
	if(pageNo > totalPages)
		pageNo = totalPages;
		
	System.out.println(totalRecords);
// 	Statement stmt = DB.createStmt(conn);
	int startPos = (pageNo-1)*PAGE_SIZE;
	if(startPos<0){
		startPos = 0;
	}
// 	String sql = "select * from article where pid = 0 order by pdate desc limit "+ startPos+","+PAGE_SIZE;
// 	if(list.size())
    List tempList = new ArrayList();
	if(startPos+PAGE_SIZE>(totalRecords-1)){
		tempList = list.subList(startPos, totalRecords);
	}else{
		tempList = list.subList(startPos, startPos+PAGE_SIZE);
	 }
	request.setAttribute("list", tempList);
	
 
 
 
 
  %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <script>
 	function query(userId){
// 	var nameVal = $('form input[name="q"]').val();
	alert(userId);
	$.post("<%=request.getContextPath() %>/show_person_user",
		{userId:userId},function(res){
		$('html').html(res);
		}
		
	);
}

function KeyDown() {
			event.returnValue = false;
			event.cancel = true;
			document.getElementById("myBtnsubmit").click();;
	}
	
	function page(pageNo){
	$.post("<%=request.getContextPath() %>/cellPerson",
		{userId:userId},function(res){
		}
		
	);
	}
 </script>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
    <link rel="stylesheet" type="text/css" href="<%=basePath %>/css/css1.css" />
    <link rel="stylesheet" type="text/css" href="<%=basePath %>/css/css2.css" />
     
    <title></title>
    <style>
    html{
    width:50%;
    height:50px;
    }
div.search_tag a {
    margin-right: 10px;
    font-size: 16px;
    text-decoration: none;
}

div.border_white {
    border: 1px solid rgb(222,222,222);;
        background-color: rgb(255,255,255);
            overflow: hidden
        
}
ul.mypage_nav li a{
width:131px;
}
input.queryinput {
    height: 28px;
    width: 160px;
    padding: 5px;
    border: solid 1px rgb(255,159,30);
        background-color: rgb(255, 255, 255);
    line-height: 16px;
    color: rgb(153, 153, 153);
    font-size: 14px;
    float: left;
}

#wrap{
width:50px;
height:50px;
}
    </style>

  </head>
  
  <body>
	<div id="wrap">
    <s:iterator value="#request.list" var="item" > 
    <div class="book_item dashed_border_bottom" style="height:200px;">
        <div class="book_pic" style="width:250px;">
            <a target="_blank" href="http://www.jiushujie.com/sell/3358027">
                <img class="book_pic"
                src="<%=path %><s:property value="#item.ii.path"/>"
                alt="2016MPA MBA MPACC管理类联考历年真题高分详解"
               />
            </a>
        </div>
        <div class="info"style="width:250px;">
            <div class="title">
                <a target="_blank" href="/sell/3358027">&nbsp;</a>
            </div>
            <div class="detail padding_10">
                <div class="buy_action" >
                    <a href="insert_item_look_user?item_id=<s:property value="#item.item_id"/>" class="button_link mail_link">详细信息</a>
                </div>
                自行车分类:
                    <s:property value="#item.classified"/>
                <br/>
                颜色: 
                    <s:property value="#item.color"/>
                <br/>
                租金： <s:property value="#item.price"/>元每<s:property value="#item.unit"/>
                <br/>
                状态:  <s:property value="#item.state"/>
                <!--<span class="line-through-price">￥46.00</span>-->
                <br/>
                新旧: <s:property value="#item.old_new"/>
                <br/>
                数量: <s:property value="#item.num"/>
                
            </div>
            <div class="user_info_tiny">
                <div style="float:left;">
                    <a href="/user/6242255" target="_blank" >
                      
                        <img  style="position: relative;bottom: 12px; left:5px" class="user_pic_tiny" src="<%=path %><s:property value="#item.owner.ui.path"/>" alt="<s:property value="#item.owner.name"/>" title="<s:property value="#item.owner.name"/>" />
                 
                    </a>
                   
                    <a  onclick="KeyDown();" target="_blank" style="position: relative;bottom: 16px; left:5px" ><s:property value="#item.owner.name"/></a>
                     	   <form action="show_person_user" method="post" style="display:none"  name="member_form">
                     	<input type="hidden" name="userId" value="<s:property value="#item.owner.id"/>">
                     	<input
							type="submit" id="myBtnsubmit" name="btnsubmit" style="display:none;" value="提交" />
                   </form>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <span title="<s:if test="#item.owner.sex=='male'">
				男生
				</s:if>
				<s:else>
				女生
				</s:else>" class="<s:if test="#item.owner.sex=='male'">
				male
				</s:if>
				<s:else>
				female
				</s:else> "  style="position: relative;bottom: 16px; left:5px"><s:if test="#item.owner_sex=='male'">
				 ♂
				</s:if>
				<s:else>
				♀
				</s:else></span>
                    &nbsp;&nbsp;&nbsp;&nbsp;<span style="position: relative;bottom: 10px;"><s:property value="#bike.owner_school"/></span>
                </div>
                <div class="comment_count"></div>
            </div>
        </div>
    </div>
    
    </s:iterator>
</div>	
   <%  session.setAttribute("temp", list);
 %>
	<table border="0" cellpadding="3" cellspacing="0" width="100%">
			<tbody>
				<tr valign="top">
					<td><span class="nobreak"> 页: 第<%=pageNo %>页，共 <%=totalPages %>页 -<span
							class="jive-paginator"> [ </span> </span>
							
							 <span class="nobreak"><span class="jive-paginator">
							 <a href="<%=path %>/index/cellContentChild.jsp?pageNo=1">第一页</a> </span> </span>
							
								 <span class="nobreak"><span class="jive-paginator">|</span></span>
								<span class="nobreak"><span class="jive-paginator">
								<a href="<%=path %>/index/cellContentChild.jsp?pageNo=<%=pageNo-1%>">上一页</a>
								
								 <span class="nobreak"><span class="jive-paginator">|</span></span>
								<span class="nobreak"><span class="jive-paginator">
								<a href="<%=path %>/index/cellContentChild.jsp?pageNo=<%=pageNo+1%>">下一页</a>
								| &nbsp;
								<a onlick="page(<%=totalPages%>)" href="<%=path %>/index/cellContentChild.jsp?pageNo=<%=totalPages%>">最末页</a>
								
								
					</td>
				</tr>
			</tbody>
		</table>
  </body>
</html>
